import simax.integrator.model.RvMessage

class BootStrap {

	def init = { servletContext ->
		println RvMessage.count
		if (RvMessage.count == 0) {
			use(groovy.time.TimeCategory) {
				Date t = new Date()	
				new RvMessage(time:t             ,command:'BESTWORK_REQ'          , from:'WORKmgr', to:'ADSsrv', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t + 2.seconds,command:'BESTWORK_REP'          , from:'ADSsrv', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t + 3.seconds,command:'TOOL_CONDITION_REQUEST', from:'WORKmgr', to:'TOOLmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t + 4.seconds,command:'TOOL_CONDITION_REPLY'  , from:'TOOLmgr', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t + 5.seconds,command:'CMR'                   , from:'WORKmgr', to:'AMHSmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +15.seconds,command:'CMR_COM'               , from:'AMHSmgr', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +18.seconds,command:'CARRIERID_READ_REPLY'  , from:'TOOLmgr', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +19.seconds,command:'TKIN'                  , from:'WORKmgr', to:'TRACKING', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +20.seconds,command:'TKIN_REP'              , from:'TRACKING', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +21.seconds,command:'WORK_START_REQUEST'    , from:'WORKmgr', to:'TOOLmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +25.seconds,command:'PROCESS_START'         , from:'TOOLmgr', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +35.seconds,command:'WORK_INFORM'           , from:'TOOLmgr', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +55.seconds,command:'PROCESS_END'           , from:'TOOLmgr', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +56.seconds,command:'TKOUT'                 , from:'WORKmgr', to:'TRACKING', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +57.seconds,command:'TKOUT_REP'             , from:'TRACKING', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +58.seconds,command:'UNLOAD_REQUEST'        , from:'WORKmgr', to:'AMHSmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +59.seconds,command:'UNLOAD_REQUEST_REP'    , from:'AMHSmgr', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
				new RvMessage(time:t +70.seconds,command:'CARRIER_MOVE_COMPLETE' , from:'AMHSmgr', to:'WORKmgr', header:'A,B,C', msgbody:'LOTID=L1 EQPID=E1').save(flush:true)
			}
		}		
	}
	
	def destroy = {
	}
}
